<template>
  <div class="profile">
    <div class="profile-one">
      <img src="https://api-haoke-web.itheima.net/img/profile/bg.png" alt="" />

      <div class="profile-two">
        <img
          src="https://api-haoke-web.itheima.net/img/profile/avatar.png"
          alt=""
        />
        <div class="profile-two-one" v-if="people === null">
          <p>游客</p>
          <p><button @click="btngo">登录</button></p>
        </div>

        <div class="profile-two-one" v-else>
          <p>xff</p>
          <p><button @click="btnlogin">退出</button></p>
          <p>编辑个人资料</p>
        </div>
      </div>
    </div>
    <div class="profile-three">
      <ul>
        <li @click="gorent"><van-icon name="wap-home-o" />我的出租</li>
        <li @click="gohistory"><van-icon name="underway-o" />看房记录</li>
        <li>
          <van-icon name="credit-pay" />
          <router-link to="/Rent/Add">成为房主</router-link>
        </li>
        <li><van-icon name="user-o" />个人资料</li>
        <li><van-icon name="service-o" />联系我们</li>
      </ul>
    </div>

    <div class="profile-four">
      <img
        src="https://api-haoke-web.itheima.net/img/profile/join.png"
        alt=""
      />
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      people: {},
    };
  },
  methods: {
    gorent() {
      this.$router.push("/Rent");
    },

    gohistory() {
      this.$router.push("/History");
    },

    peoplelist() {
      this.$http.get("/user").then((res) => {
        console.log(res);
        this.people = res.data.body;
        console.log(this.people);
      });
    },

    btnlogin() {
      localStorage.clear();
      this.peoplelist();
    },

    btngo() {
      this.$router.push("/Login");
    },
  },
  created() {
    this.peoplelist();
  },
};
</script>

<style>
.profile {
  width: 100%;
  height: 100%;
}
.profile-one {
  width: 100%;
  height: 320px;
  position: relative;
}
.profile-one img {
  width: 100%;
}
.profile-two {
  width: 85%;
  height: 170px;
  background: #fff;
  position: absolute;
  left: 50%;
  top: 75%;
  transform: translate(-50%, -60%);
  box-shadow: 1px 1px 5px 2px #ccc;
}
.profile-two img {
  width: 20%;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  border: 5px solid #fff;
  border-radius: 50%;
  box-shadow: 1px 1px 5px 2px #ccc;
}
.profile-three {
  width: 100%;
  height: 180px;
  padding: 0 10px;
}
.profile-three ul {
  width: 100%;
  height: 180px;
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  align-items: center;
}
.profile-three ul li {
  line-height: 60px;
  width: calc(100% / 3);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.profile-three ul li i {
  font-size: 20px;
}
.profile-four {
  width: 100%;
  height: 90px;
  padding: 0 10px;
}
.profile-four img {
  width: 100%;
}
.profile-two-one {
  width: 100%;
  height: 130px;
  margin: 35px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 16px;
}
</style>